package com.andy.buyu.server.dto;

import com.andy.buyu.server.socket.GmAction;

import io.netty.buffer.ByteBuf;

/**
 * 客户端消息编码
 * @author cuiwm
 */
public class ClientMsgWriter extends BaseMessage{
	
    private Object[] params;
    
    public ClientMsgWriter(Integer cmd,Object... params) {
    	this.cmd = cmd;
    	this.params = params;
	}

	@Override
	public void writeBody(ByteBuf buf) {
		switch (cmd) {
		case GmAction.ACTION_100:
			writeString(buf, params[0].toString());
			break;
		case GmAction.ACTION_111:
			buf.writeInt((int) params[0]);
			buf.writeByte((int) params[1]);
			break;
		case GmAction.ACTION_118:
			buf.writeByte((int) params[0]);
			break;
		case GmAction.ACTION_200:
			buf.writeInt((int) params[0]);
			buf.writeInt((int) params[1]);
			break;
		case GmAction.ACTION_202:
			buf.writeByte((int) params[0]);
			buf.writeInt((int) params[1]);
			break;
		case GmAction.ACTION_203:
			buf.writeByte((int) params[0]);
			break;
		case GmAction.ACTION_204:
			buf.writeInt((int) params[0]);
			break;

		default:
			break;
		}
	}


}